#ifndef _STREAMBLOQUEANTE_H_
#define _STREAMBLOQUEANTE_H_

#include <map>
#include <fstream>
#include <iostream>
#include <ios>
#include "Mutex.h"
#include "Lock.h"

class StreamBloqueante {

	std::fstream s;
	std::string path;
	static std::map<std::string, Mutex> openFiles;
public:

	StreamBloqueante(std::string &string, std::ios_base::openmode mode);

    //Al unwindear stack:
    // 1)cierra el stream.
    // 2) unlockea mutex
	~StreamBloqueante();

	void close();

	std::fstream& stream();

};

#endif
